package com.example.apprendrechinois.pinyin;

import com.example.apprendrechinois.R;
import com.example.apprendrechinois.model.language.Vowel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;

public class AdVowelButton extends ArrayAdapter<Vowel> {

	public AdVowelButton(Context context, Vowel[] vowels) {
		super(context, R.layout.ad_vowel_button, vowels);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Vowel v = getItem(position);
		Button butVowel = null;
		if(convertView != null){
			butVowel = (Button)convertView;			
		}
		else {
			butVowel = (Button)LayoutInflater.from(getContext()).inflate(R.layout.ad_vowel_button, null);
		}
		fillButton(butVowel, v);
		return butVowel;		
	}

	private void fillButton(Button butVowel, Vowel v) {
		butVowel.setText(v.prononciation);		
	}
	
	
	
	

}
